package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicOtherInwhItemDAO;
import com.cssy.yd.logic.entity.LogicOtherInwhItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-05-23
 */
public class LogicOtherInwhItemDAOImpl extends SqlMapClientDaoSupport implements LogicOtherInwhItemDAO {

    /**
     * 插入数据
     * @param logicOtherInwhItemDO
     * @return 插入数据的主键
     */
    public String insertLogicOtherInwhItemDO(LogicOtherInwhItemDO logicOtherInwhItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicOtherInwhItem.insert", logicOtherInwhItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicOtherInwhItemDO
     * @return 查出的记录数
     */
    public Integer countLogicOtherInwhItemDOByExample(LogicOtherInwhItemDO logicOtherInwhItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicOtherInwhItem.countByDOExample", logicOtherInwhItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicOtherInwhItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicOtherInwhItemDO(LogicOtherInwhItemDO logicOtherInwhItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicOtherInwhItem.update", logicOtherInwhItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicOtherInwhItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicOtherInwhItemDO> findListByExample(LogicOtherInwhItemDO logicOtherInwhItemDO) throws DataAccessException {
        List<LogicOtherInwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicOtherInwhItem.findListByDO", logicOtherInwhItemDO);
        return list;
    }

    /**
     * 根据主键获取logicOtherInwhItemDO
     * @param id
     * @return logicOtherInwhItemDO
     */
    public LogicOtherInwhItemDO findLogicOtherInwhItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicOtherInwhItemDO logicOtherInwhItemDO = (LogicOtherInwhItemDO) getSqlMapClientTemplate().queryForObject("LogicOtherInwhItem.findByPrimaryKey", id);
        return logicOtherInwhItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicOtherInwhItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicOtherInwhItem.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicOtherInwhItemDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicOtherInwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicOtherInwhItem_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicOtherInwhItem_ex.count", scs);
  	      return count;
  	}
	
	@Override
	public List<LogicOtherInwhItemDO> findByPid(String pid)
			throws DataAccessException {
		List<LogicOtherInwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicOtherInwhItem_ex.findByPid", pid);
		return list;
	}

	@Override
	public void deleteByPid(String pid) throws DataAccessException {
		getSqlMapClientTemplate().delete("LogicOtherInwhItem_ex.deleteByPid",pid);
	}
}